/**
 * @author SaoE
 * @date 2025/3/22 15:08
 */
public class _240 {
    public boolean searchMatrix(int[][] matrix, int target) {
        int right = matrix[0].length - 1;
        for(int i = 0; i < matrix.length; i++){
            for (int j = 0; j <= right; j++){
                if (matrix[i][j] == target){
                    return true;
                }
                if (matrix[i][j] > target){
                    right = j - 1;
                    break;
                }
            }
            if (right < 0){
                return false;
            }
        }
        return false;
    }
}
